﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyDoiXe.Lop_du_lieu;

namespace QuanLyDoiXe.lop_doi_tuong
{
    class lop_capnhienlieu
    {
        string Mxe,MNVC,MDM;
        DateTime Ngaycap;
        int Dungtichbinh,Chisocu,Solitcap;
        public lop_capnhienlieu(){}
        public lop_capnhienlieu(string Mxe, int Dungtichbinh, int Chisocu, string MDM, int Solitcap, DateTime Ngaycap, string MNVC)
        {
            this.Mxe = Mxe;
            this.Dungtichbinh = Dungtichbinh;
            this.Chisocu = Chisocu;
            this.MDM = MDM;
            this.Solitcap = Solitcap;
            this.Ngaycap = Ngaycap;
            this.MNVC = MNVC;
        }
        #region Các phương thức hoạt động
        public bool taomoi()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("insert into capnhienlieuchoxe values ('" + Mxe + "','" + MNVC + "','" + MDM + "','" + Dungtichbinh + "','" + Chisocu + "','" + Solitcap + "')") == 1)
            {
               lop_ket_noi.huyketnoi();
               return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool capnhat()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("update capnhienlieuchoxe set MNVC='" + MNVC + "',MDM='" + MDM + "',Dungtichbinh='" + Dungtichbinh + "',Chisocu='" + Chisocu + "',Solitcap='" + Solitcap + "' where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool xoa()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("delete from capnhienlieuchoxe where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        #endregion
    }
}
